package com.navi.heartbeat.job;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;
import com.rabbitmq.client.GetResponse;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;

/**
 * LoadMqJob
 *
 * @author Matthew
 * @date 2018-07-04
 */
public class LoadMqJob {

  private static final Logger logger = LoggerFactory.getLogger(LoadMqJob.class);

  @Autowired
  private ConnectionFactory connectionFactory;

/*  private void loadSysAlarm() throws IOException, TimeoutException {
    try (Connection connection = connectionFactory.newConnection()) {
      final Channel channel = connection.createChannel();
      channel.exchangeDeclare("qmsExchange", ExchangeTypes.TOPIC, true);
      while (true) {
        final GetResponse response = channel.basicGet("SYSTEM_ALARM", true);
        if(response == null){
          break;
        }
        if (response.getBody() == null) {
          break;
        }
        String message = new String(response.getBody(), "utf-8");
        System.out.println(message);
        *//*if (!StringUtils.isEmpty(message)) {
          wrtmAlarmFService.subMainProc(message);
        }*//*

      }
    } catch (Exception ex) {
      logger.error("Rabbit MQ 连接异常, {}", ex);
    }
  }*/
}
